<template>
    <div>
        <ly-dialog v-model="dialogVisible" :title="loadingTitle" width="560px" :before-close="handleClose">
            <el-table :border="true" :data="priceTable" v-loading="loadingPage" ref="tableref" >
                <el-table-column width="60" type="selection" align="center"></el-table-column>
                <el-table-column width="200" prop="name" label="元件名称"show-overflow-tooltip></el-table-column>
                <el-table-column width="150" prop="price" label="单价">
                  <template #default="scope">
                    <el-input v-model="scope.row.price"></el-input>
                  </template>
                </el-table-column>
            </el-table>

            <template #footer>
                <el-button @click="handleClose" :loading="loadingSave">取消</el-button>
                <el-button type="primary" @click="submitData" :loading="loadingSave">确定</el-button>
            </template>
        </ly-dialog>
    </div>
</template>

<script>
    import {mallPojectAdd,mallPojectEdit,mallPojectUpload} from "@/api/api";
    import LyDialog from "../../../components/dialog/dialog";
    export default {
        name: "addUser",
        components: {LyDialog},
        emits: ['refreshData'],
        data() {
            return {
                dialogVisible:false,
                loadingSave:false,
                loadingTitle:'',
                loadingPage:false,
                priceTable:[]
            }
        },
        methods:{
            handleClose() {
                this.dialogVisible=false
                this.loadingSave=false
            },
            addModuleFn(item,flag) {
                this.loadingTitle=flag
                this.dialogVisible=true
                let that=this
                this.priceTable=[]
                item.forEach(element => {
                    that.priceTable.push({
                        name:element,
                        price:0
                    })
                });
            },
            submitData() {
                this.$emit('refreshData',this.priceTable)
                this.handleClose()
            }
        }
    }
</script>
<style scoped>
    .avatar-uploader .el-upload {
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
      border-color: #409EFF;
    }
    .avatar-uploader-icon {
      font-size: 28px;
      color: #8c939d;
      width: 128px;
      height: 128px;
      line-height: 128px;
      text-align: center;
    }
    .avatar {
      width: 128px;
      height: 128px;
      display: block;
    }
</style>

